import request from "@/utils/request";

import type { ChatHistoryDTO } from "@/types/aichat_history/ChatHistoryDTO";
import type { ChatHistoryVO } from "@/types/aichat_history/ChatHistoryVO";
import type { ChatDetailsMessageVO } from "@/types/aichat_history/ChatDetailsMessageVO";

/**
 * 获取对话历史记录列表
 * @param params 包含userNo和type的查询参数
 * @returns 对话历史记录列表
 */
export const getChatHistoriesByUserNo = (data: ChatHistoryDTO) => {
  return request.post(
    "/api/ai/history/list",
    {
      ...data,
    },
    {
      headers: {
        "Content-Type": "application/json",
      },
    }
  );
};

/**
 * 获取某个对话的历史消息详情
 * @param chatId 对话ID
 * @returns 消息列表
 */
export const getChatDetailsMessages = (chatId: string) => {
  return request.get(`/api/ai/history/${chatId}`);
};

/**
 * 删除用户某个对话的历史记录
 * 
 * @param data 包含userNo和type的查询参数
 * @returns Void
 */
export const deleteChatHistory = (data: ChatHistoryDTO) => {
  return request.deleteWithData(
    "/api/ai/history/delete",
    {
      ...data,
    },
    {
      headers: {
        "Content-Type": "application/json",
      },
    }
  );
};

/**
 * 
 * 修改用户某个对话的历史记录（标题）
 * @param data 包含userNo和type的查询参数
 * @returns Void
 */
export const editChatHistory = (data: ChatHistoryDTO) => {
  return request.put(
    "/api/ai/history/edit",
    {
      ...data,
    },
    {
      headers: {
        "Content-Type": "application/json",
      },
    }
  );
};
